//
//  CustomUIView.m
//  UI03_UIView
//
//  Created by aaaaaa on 16/6/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CustomUIView.h"

@implementation CustomUIView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)dealloc
{
    [_leftLable release];
    [_rightTextField release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        _leftLable = [[UILabel alloc] init];
        _rightTextField = [[UITextField alloc] init];
        
        [self addSubview:self.leftLable];
        [self addSubview:self.rightTextField];
        
        [_leftLable release];
        [_rightTextField release];
        
        self.rightTextField.delegate = self;
        
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame withLableText:(NSString *)lableText withTextFieldPlaceholdser:(NSString *)textFieldPlaceholder{
    self = [self initWithFrame:frame];
    if (self) {
        self.leftLable.text = lableText;
        self.leftLable.frame = CGRectMake(0, 0, frame.size.width * 0.3, frame.size.height);
        
        self.rightTextField.placeholder = textFieldPlaceholder;
        self.rightTextField.frame = CGRectMake(frame.size.width * 0.3, 0, frame.size.width * 0.7, frame.size.height);
        
        [self setTextFieldProperty];
    }
    return self;
}

- (void)setTextFieldProperty{
    self.rightTextField.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.rightTextField.layer.borderWidth = 1.0f;
    self.rightTextField.layer.cornerRadius = 5.0;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [textField resignFirstResponder];
    return YES;
}

















@end
